package com.fowo.api.service.handleWork;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import com.fowo.api.entity.LogisticsOrder;
import com.fowo.api.model.logistics.order.LogisticsOrderAgainOrderAction;
import com.fowo.api.model.nav.sell.order.NavSellOrderVo;
import com.fowo.api.service.impl.LogisticsOrderServiceImpl;
import com.fowo.api.service.impl.NavSellOrderServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Component
@Slf4j
public class LogisticsOrderAgainOrderActionService implements LogisticsOrderAgainOrderAction {

    @Resource
    private LogisticsOrderServiceImpl logisticsOrderService;
    @Resource
    private NavSellOrderServiceImpl navSellOrderService;

    @Override
    public void run(List<Long> idList) throws Exception {
        Assert.isTrue(CollUtil.isNotEmpty(idList), "参数异常!");

        final List<NavSellOrderVo> navSellOrderVos = navSellOrderService.getVoByIdList(idList, true);
        Assert.isTrue(CollUtil.isNotEmpty(navSellOrderVos), "请选择对应订单!");
        //物流下单
        navSellOrderService.doLogisticsOrder(navSellOrderVos);
    }
}
